package com.amiba.crm.admin.auth.core.validate.code.config;

import com.amiba.crm.admin.auth.core.validate.code.ValidateCodeFilter;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author HZI.HUI
 * 2019/5/23 15:47
 */
@Configuration
public class ValidateCodeFilterConfig {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private ObjectMapper objectMapper;
    @Bean
    public FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean bean = new FilterRegistrationBean();
        bean.setFilter(new ValidateCodeFilter(redisTemplate,objectMapper));
        bean.addUrlPatterns("/oauth/token");
        return bean;
    }
}
